
export default(url,data={},method='GET')=>{
  return new Promise((resolve,reject)=>{
    wx.request({
        url:'https://netease-cloud-music-api-woad-delta.vercel.app'+url,
        data,
        method,
        header: {
            cookie: uni.getStorageSync('cookies')?uni.getStorageSync('cookies').find(item => item.indexOf('MUSIC_U') !== -1):''
          },
          success: (res) => {
            if(data.isLogin){// 登录请求
              // 将用户的cookie存入至本地
              uni.setStorage({
                key: 'cookies',
                data: res.cookies
              })
            }
            resolve(res.data); // resolve修改promise的状态为成功状态resolved
          },
          fail: (err) => {
            // console.log('请求失败: ', err);
            reject(err); // reject修改promise的状态为失败状态 rejected
          }
      })
  })
}